package com.googlecode.cnasort.cc.rmi.common;

import java.rmi.Remote;
import java.rmi.RemoteException;

import com.googlecode.cnasort.cc.rmi.common.data.RMIDirectory;
import com.googlecode.cnasort.cc.rmi.common.data.RMIFile;
import com.googlecode.cnasort.cc.rmi.common.data.RMIFileLoader;
import com.googlecode.cnasort.cc.rmi.common.data.RMIFileLoaderId;

/**
 * RMI Service
 */
public interface RMIFileLoaderConnector extends Remote
{
    public static final String SERVICE_NAME = "RMIFileLoaderConnector";

    /**
     * Connect to {@link RMIFileLoader}, other will fail if connect() has not success call.
     *
     * @param id Id for authentification process
     * @return true if connected, false otherwise
     * @throws RemoteException if any
     */
    public boolean connect( RMIFileLoaderId id ) throws RemoteException;

    public void disconnect(RMIFileLoaderId id) throws RemoteException;

    public RMIDirectory[] getRootDirectories(RMIFileLoaderId id)
        throws RemoteException;

    public RMIDirectory[] getDirectories(RMIFileLoaderId id, RMIDirectory directory)
        throws RemoteException;

    public RMIFile[] getFiles(RMIFileLoaderId id, RMIDirectory directory)
        throws RemoteException;

    //public byte[] getFileContent(RMIFileLoaderId id, RMIFile file) throws RemoteException;

    public void setFileTransfertBufferSize(RMIFileLoaderId id, int maxBufferSize)
        throws RemoteException;

    public int getFileTransfertBufferSize(RMIFileLoaderId id)
        throws RemoteException;

    public void openFileTransfert(RMIFileLoaderId id, RMIFile file)
        throws RemoteException;

    public boolean isFileTransfertComplete(RMIFileLoaderId id)
        throws RemoteException;

    public byte[] nextFileTransfertPart(RMIFileLoaderId id)
        throws RemoteException;

    public void closeFileTransfert(RMIFileLoaderId id) throws RemoteException;

    public void quit() throws RemoteException;
}
